.\" Copyright (c) 2002-2018 Julien Nadeau Carriere <vedge@csoft.net>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
.\" (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd September 21, 2009
.Dt AG_GLOBALKEYS 3
.Os
.ds vT Agar API Reference
.ds oS Agar 1.4
.Sh NAME
.Nm AG_GlobalKeys
.Nd agar application-wide keyboard shortcuts
.Sh SYNOPSIS
.Bd -literal
#include <agar/core.h>
#include <agar/gui.h>
.Ed
.Sh DESCRIPTION
The
.Nm
interface associates application-wide keyboard shortcuts to specified
callback routines.
.Pp
Note that
.Nm
entirely ignores the status of Agar windows and widgets.
To implement keyboard operations specific to a given Agar window or widget,
one would instead use
.Xr AG_ActionOnKeyDown 3
or
.Xr AG_ActionOnKeyUp 3 .
For a more low-level interface to keyboard processing, the base
.Xr AG_Widget 3
class also provides the
.Sq key-down
and
.Sq key-up
event handlers.
.Sh INTERFACE
.nr nS 1
.Ft void
.Fn AG_BindGlobalKey "AG_KeySym key" "AG_KeyMod mod" "void (*fn)(void)"
.Pp
.Ft void
.Fn AG_BindGlobalKeyEv "AG_KeySym key" "AG_KeyMod mod" "void (*fn)(AG_Event *)"
.Pp
.Ft void
.Fn AG_BindStdGlobalKeys "void"
.Pp
.Ft int
.Fn AG_UnbindGlobalKey "AG_KeySym key" "AG_KeyMod mod"
.Pp
.Ft void
.Fn AG_ClearGlobalKeys "void"
.Pp
.nr nS 0
.Fn AG_BindGlobalKey
binds the specified routine to the given key combination.
Keys are represented by
.Ft AG_KeySym
enums, and acceptable values for
.Fa sym
and
.Fa mod
arguments are listed under
.Xr AG_KeySym 3
and
.Xr AG_KeyMod 3 .
.Pp
The
.Fn AG_BindGlobalKeyEv
variant accepts an
.Xr AG_Event 3
style function.
Note that arguments of
.Dv AG_KEY_ANY
and
.Dv AG_KEYMOD_ANY
are acceptable, in which case any key or key modifier will be matched.
.Pp
The
.Fn AG_BindStdGlobalKeys
routine sets up the standard key bindings:
.Pp
.Bl -tag -width "CTRL+EQUALS / META+EQUALS " -compact
.It CTRL+EQUALS / META+EQUALS
.Xr AG_ZoomIn 3
.It CTRL+MINUS / META+MINUS
.Xr AG_ZoomOut 3
.It CTRL+0 / META+0
.Xr AG_ZoomReset 3
.It CTRL+Q / META+Q
.Xr AG_QuitGUI 3
.It ESCAPE
.Xr AG_CloseFocusedWindow 3
.El
.Pp
.Fn AG_UnbindGlobalKey
removes the given key mapping.
.Fn AG_ClearGlobalKeys
removes all existing key mappings.
.Sh SEE ALSO
.Xr AG_Intro 3 ,
.Xr AG_Keyboard 3 ,
.Xr AG_KeyMod 3 ,
.Xr AG_KeySym 3 ,
.Xr AG_Widget 3 ,
.Xr AG_Window 3
.Sh HISTORY
The
.Nm
interface first appeared in Agar 1.0.
.Fn AG_BindStdGlobalKeys
first appeared in Agar 1.5.0.
